//
//  DZQualityHeadCell.m
//  DaoZiJinFu
//
//  Created by dzjf on 2017/1/13.
//  Copyright © 2017年 dzjf. All rights reserved.
//

#import "DZQualityHeadCell.h"

@implementation DZQualityHeadCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _purchaseAmount.textColor = [UIColor whiteColor];
    _availableAmount.textColor = [UIColor whiteColor];
    _allTime.textColor = [UIColor whiteColor];
    _allTime.text = @"";
    _presentVlue.text = @"";
    _purchaseAmount.text = @"";
    _availableAmount.text = @"";
    self.clipsToBounds = YES;
}

- (void)setModel:(DZQualityModel *)model {
    if(!model)return;
    _model = model;
    _availableAmount.text = [NSString stringWithFormat:@"%.0lf元",_model.remaining_investment_amount];
    _purchaseAmount.text = [NSString stringWithFormat:@"%.0lf元",_model.buy_min_amount];
    _allTime.text = [NSString stringWithFormat:@"%ld天",_model.day_number];
    [self setColors:[UIColor whiteColor]];
}

- (void)setColors:(UIColor *)color {
    NSString *yieldStr = [NSString stringWithFormat:@"%.2lf",_model.annual_gains*100];
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%%",yieldStr]];
    NSDictionary *amountAttr = @{NSFontAttributeName:[UIFont systemFontOfSize:52.0f],NSForegroundColorAttributeName:color};
    NSDictionary *yuanAttr = @{NSFontAttributeName:[UIFont systemFontOfSize:22.0f],NSForegroundColorAttributeName:color};
    [attrStr setAttributes:amountAttr range:NSMakeRange(0, yieldStr.length)];
    [attrStr setAttributes:yuanAttr range:NSMakeRange(yieldStr.length, 1)];
    _presentVlue.attributedText = [[NSAttributedString alloc] initWithAttributedString:attrStr];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
